import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-08-09
 * Time: 11:27
 */
public class Test {
    public static void main(String[] args) {
        MyStack satck = new MyStack();
        //压栈
        satck.push(1);
        satck.push(2);
        satck.push(3);
        satck.push(4);
        //size 求栈里的数据长度
        int length = satck.size();
        System.out.println(length);//4
        //search 获取栈里元素下标 从栈顶开始数
        int index = satck.search(4);
        System.out.println(index);//1
        //获取栈顶元素 不删除
        int val = satck.peek();
        System.out.println(val);//4
        //出栈 删除栈顶元素
        int val2 = satck.pop();
        System.out.println(val2);//4
        //再次获取新的栈顶元素
        val = satck.peek();
        System.out.println(val);//3
        //清空栈
        satck.pop();
        satck.pop();
        satck.pop();
        boolean flg = satck.isEmpty();
        System.out.println(flg);
    }

    public static void main1(String[] args) {
        Stack<Integer> satck = new Stack<>();
        //压栈
        satck.push(1);
        satck.push(2);
        satck.push(3);
        satck.push(4);
        //size 求栈里的数据长度
        int length = satck.size();
        System.out.println(length);//4
        //search 获取栈里元素下标 从栈顶开始数
        int index = satck.search(4);
        System.out.println(index);//1
        //获取栈顶元素 不删除
        int val = satck.peek();
        System.out.println(val);//4
        //出栈 删除栈顶元素
        int val2 = satck.pop();
        System.out.println(val2);//4
        //再次获取新的栈顶元素
         val = satck.peek();
        System.out.println(val);//3
        //清空栈
        satck.pop();
        satck.pop();
        satck.pop();
        boolean flg = satck.empty();
        System.out.println(flg);
    }
}
